<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateVolunteerActivitiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('volunteer_activities', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('自增ID');

            $table->string('title', 300)->comment('活动标题');
            $table->string('image', 300)->comment('封面图');
            $table->string('content', 3000)->comment('内容');

            $table->timestamp('sign_up_start')->comment('开始报名时间');
            $table->timestamp('sign_up_end')->comment('结束报名时间');
            $table->timestamp('activity_time_start')->comment('开始活动时间');
            $table->timestamp('activity_time_end')->comment('结束活动时间');

            $table->unsignedInteger('limit_count')->comment('报名人数限制');
            $table->unsignedInteger('post_count')->comment('岗位数');

            $table->string('service_object', 300)->comment('服务对象');
            $table->string('volunteer_support', 500)->comment('志愿者保障');
            $table->string('service_time', 500)->comment('服务时间');

            $table->unsignedTinyInteger('status')->default(0)->comment('状态 0:关闭 1:开启');
            $table->unsignedBigInteger('publisher_uid')->comment('发布者uid')->index();

            $table->timestamps();
            $table->softDeletes();

            $table->engine = 'InnoDB';

        });
        Schema::create('volunteer_forms', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('自增ID');

            $table->unsignedBigInteger('volunteer_id')->comment('志愿活动id')->index();
            $table->string('name', 100)->comment('姓名');
            $table->unsignedTinyInteger('sex')->default(0)->comment('性别 0:未知 1:男 2:女');
            $table->unsignedInteger('age')->nullable()->comment('年龄');
            $table->string('phone', 100)->nullable()->comment('手机号码');
            $table->string('id_card', 100)->nullable()->comment('身份证');
            $table->string('work_unit', 500)->nullable()->comment('工作单位');
            $table->string('address', 500)->nullable()->comment('住址');

            $table->unsignedTinyInteger('audit_status')->default(0)->comment('审核状态 0:待审核 1:已审核 2:拒绝');
            $table->unsignedBigInteger('add_uid')->comment('添加者uid')->index();

            $table->timestamps();
            $table->softDeletes();

            $table->engine = 'InnoDB';
        });

        DB::statement("alter table `volunteer_activities` comment'志愿活动表'");
        DB::statement("alter table `volunteer_forms` comment'志愿者活动报名表'");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('volunteer_activities');
    }
}
